package com.lk.exception;

import com.lk.util.Result;
import org.springframework.security.oauth2.common.exceptions.OAuth2Exception;
import org.springframework.security.oauth2.provider.ClientRegistrationException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author : com.com.lk
 * @date 2021/11/21 15:12
 **/
@RestControllerAdvice
public class GlobException {


    @ExceptionHandler(ClientRegistrationException.class)
    public Result handleClientRegistrationException(ClientRegistrationException e) {

        return Result.fail(408, e.getMessage());
    }

    @ExceptionHandler(OAuth2Exception.class)
    public Result handleException(OAuth2Exception e) {

        return Result.fail(409, e.getMessage());
    }

    @ExceptionHandler(value = Exception.class)
    public Result ex(Exception e) {
        return Result.of(500, e.getMessage(), null);
    }
}
